<form id="match_add" enctype="multipart/form-data" action="administrator-match-add" method="post">
<table class="TableA" width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#CEE7FF">
	<tr>
		<td height="25" align="right">比赛时间：*</td>
		<td height="25" align="left">
			<input type="text" id="MatchTime" name="MatchTime" value="<?php echo ($this->param['MatchTime']) ? date('Y-m-d H:i:s',$this->param['MatchTime']) : date('Y-m-d H:i:s')?>" />
		</td>
	</tr>
	<tr>
		<td height="25" align="right">比赛A队：*</td>
		<td height="25" align="left">
			<select stype="<?php echo $this->param['TeamTypeA']?>" steam="<?php echo $this->param['TeamA']?>" pteam="A" name="TeamTypeA" class="TeamType">
				<option value="">请选择</option>
				<option value="club">俱乐部</option>
				<option value="national">国家队</option>
			</select>
		</td>
	</tr>
	<tr>
		<td height="25" align="right">A队logo：*</td>
		<td height="25" align="left">
			<span><input name="productpic" type="file" /></span> <input type="button" onclick="uploadImgA(this);" value="上传" />
			<div id="productImagesA">
				<?php if($this->param['TeamALogo'] != ''):?>
				<div style="margin:10px"><a href="<?php echo $this->param['TeamALogo']?>" target="_blank"><img style="height:100px;width:100px;vertical-align:middle;" src="<?php echo $this->param['TeamALogo']?>" /></a><input type="hidden" name="TeamALogo" value="<?php echo $this->param['TeamALogo']?>" />
				<?php endif;?>
			</div>
		</td>
	</tr>
	<tr>
		<td height="25" align="right">A队赔率：*</td>
		<td height="25" align="left">
			<input type="text" id="TeamARate" name="TeamARate" value="<?php echo $this->param['TeamARate']?>" />
		</td>
	</tr>
	<tr>
		<td height="25" align="right">A队成绩：</td>
		<td height="25" align="left">
			<input type="text" <?php if($this->param['MatchStatus'] != 2) {?>readonly="readonly"<?php }?> id="TeamAScore" name="TeamAScore" value="<?php echo ($this->param['TeamAScore'] > 0) ? $this->param['TeamAScore'] : 0?>" /> <b style="color: red;">注：比赛成绩仅在比赛后才能输入</b>
		</td>
	</tr>
	<tr>
		<td height="25" align="right">比赛B队：*</td>
		<td height="25" align="left">
			<select stype="<?php echo $this->param['TeamTypeB']?>" steam="<?php echo $this->param['TeamB']?>" pteam="B"  name="TeamTypeB" class="TeamType">
				<option value="">请选择</option>
				<option value="club">俱乐部</option>
				<option value="national">国家队</option>
			</select>
		</td>
	</tr>
	<tr>
		<td height="25" align="right">B队logo：*</td>
		<td height="25" align="left">
			<span><input name="productpic1" type="file" /></span> <input type="button" onclick="uploadImgB(this);" value="上传" />
			<div id="productImagesB">
				<?php if($this->param['TeamBLogo'] != ''):?>
				<div style="margin:10px"><a href="<?php echo $this->param['TeamBLogo']?>" target="_blank"><img style="height:100px;width:100px;vertical-align:middle;" src="<?php echo $this->param['TeamBLogo']?>" /></a><input type="hidden" name="TeamBLogo" value="<?php echo $this->param['TeamBLogo']?>" />
				<?php endif;?>
			</div>
		</td>
	</tr>
	<tr>
		<td height="25" align="right">B队赔率：*</td>
		<td height="25" align="left">
			<input type="text" id="TeamBRate" name="TeamBRate" value="<?php echo $this->param['TeamBRate']?>" />
		</td>
	</tr>
	<tr>
		<td height="25" align="right">B队成绩：</td>
		<td height="25" align="left">
			<input type="text" <?php if($this->param['MatchStatus'] != 2) {?>readonly="readonly"<?php }?> id="TeamBScore" name="TeamBScore" value="<?php echo ($this->param['TeamBScore'] > 0) ? $this->param['TeamBScore'] : 0?>" /> <b style="color: red;">注：比赛成绩仅在比赛后才能输入</b>
		</td>
	</tr>
	<tr>
		<td height="25" align="right">比赛logo：*</td>
		<td height="25" align="left">
			<span><input name="productpic2" type="file" /></span> <input type="button" onclick="uploadImgM(this);" value="上传" />
			<div id="productImagesM">
				<?php if($this->param['MatchLogo'] != ''):?>
				<div style="margin:10px"><a href="<?php echo $this->param['MatchLogo']?>" target="_blank"><img style="height:100px;width:100px;vertical-align:middle;" src="<?php echo $this->param['MatchLogo']?>" /></a><input type="hidden" name="MatchLogo" value="<?php echo $this->param['MatchLogo']?>" />
				<?php endif;?>
			</div>
		</td>
	</tr>
	<tr>
		<td height="25" align="right">比赛状态：</td>
		<td height="25" align="left">
			<select name="MatchStatus" id="MatchStatus">
				<option value="0" <?php echo ($this->param['MatchStatus'] == 0) ? 'selected=\"selected\"': ''?>>未开始</option>
				<option value="1" <?php echo ($this->param['MatchStatus'] == 1) ? 'selected=\"selected\"': ''?>>进行中</option>
				<option value="2" <?php echo ($this->param['MatchStatus'] == 2) ? 'selected=\"selected\"': ''?>>未发放</option>
				<option value="3" <?php echo ($this->param['MatchStatus'] == 3) ? 'selected=\"selected\"': ''?>>已发放</option>
			</select>
		</td>
	</tr>
	<tr>
		<td height="25" align="right">&nbsp;</td>
		<td height="25" align="left">&nbsp;</td>
	</tr>
	<tr>
		<td colspan="2" width="100%" align="center" style="background-color: #eee">
			<input type="submit" value="确认提交" />&nbsp;&nbsp;<input type="button" value="返回" onclick="window.history.go(-1);" />
		</td>
	</tr>
	<?php if($this->param['errormsg'] != '') {?>
	<tr>
	  <td height="25" align="right">错误信息：</td>
	  <td height="25" align="left"><b style="font-size: 14px;color: red;"><?php echo $this->param['errormsg']?></b></td>
	</tr>
	<?php }?>
</table>
</form>
<iframe id="productIframe" width="0" height="0" name="productIframe"></iframe>
<style>
	.TableA { border-collapse:collapse }
	.TableA tr td { padding: 4px; }
</style>
<script type="text/javascript">
	upload.type='match';
	upload.formid='match_add';
	
	function uploadImgA(thisInput){
		upload.setAppend=function(imgurl){
			return '<div style="margin:10px"><a href="'+imgurl+'" target="_blank"><img style="height:100px;width:100px;vertical-align:middle;" src="'+imgurl+'" /></a><input type="hidden" name="TeamALogo" value="'+imgurl+'" /></div>';
		}
	     upload.setImg=function(imgurl){
	        this.imgurl=imgurl;
			$('#productImagesA').html(this.setAppend(imgurl));
			parent.shutMsg();
			commonEffection.resetFrame('admins_frame',true);
		}
		upload.uploadimg(thisInput);
	}

	function uploadImgB(thisInput){
		upload.setAppend=function(imgurl){
			return '<div style="margin:10px"><a href="'+imgurl+'" target="_blank"><img style="height:100px;width:100px;vertical-align:middle;" src="'+imgurl+'" /></a><input type="hidden" name="TeamBLogo" value="'+imgurl+'" /></div>';
		}
	     upload.setImg=function(imgurl){
	        this.imgurl=imgurl;
			$('#productImagesB').html(this.setAppend(imgurl));
			parent.shutMsg();
			commonEffection.resetFrame('admins_frame',true);
		}
		upload.uploadimg(thisInput);
	}

	function uploadImgM(thisInput){
		upload.setAppend=function(imgurl){
			return '<div style="margin:10px"><a href="'+imgurl+'" target="_blank"><img style="height:100px;width:100px;vertical-align:middle;" src="'+imgurl+'" /></a><input type="hidden" name="MatchLogo" value="'+imgurl+'" /></div>';
		}
	     upload.setImg=function(imgurl){
	        this.imgurl=imgurl;
			$('#productImagesM').html(this.setAppend(imgurl));
			parent.shutMsg();
			commonEffection.resetFrame('admins_frame',true);
		}
		upload.uploadimg(thisInput);
	}
	
	
	$(function($) {
		$(".TeamType").change(function(){
			var thisSlect = this;
			if($(thisSlect).next().is('select'))
			{
				$(thisSlect).next().remove();
			}
			if($(thisSlect).val() != '') {
				$(thisSlect).after('<img id="flloading" style="margin-left:5px" src="html/images/fl_loading.gif" />');
				$.post(ROOT_PATH+"/administrator-match-getteamsajax",{type:$(this).val()},function(data) {
					$('#flloading').remove();
					eval("var flArray="+data);
					if(flArray.length!=0){
						var selectString=' <select name="Team'+ $(thisSlect).attr("pteam") +'">';
						for(var i=0;i<flArray.length;i++){
							if($(thisSlect).attr("steam") == flArray[i].flid) {
								selectString+="<option selected=\"selected\" value="+flArray[i].flid+">"+flArray[i].flname+"</option>";
							} else {
								selectString+="<option value="+flArray[i].flid+">"+flArray[i].flname+"</option>";
							}
						}
						selectString+='</select> ';
						$(thisSlect).after(selectString);
					}
				});
			}
		});

		$(".TeamType").each(function(){
			if($(this).attr("stype") != '')
			{
				$(this).val($(this).attr("stype"));
				$(this).trigger('change');
			}
		});
	});
</script>